package co.com.smart.session;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import co.com.bean.WordBeanLocal;
import co.com.bean.area.AreaBeanLocal;
import co.com.bean.asignatura.AsignaturaBeanLocal;
import co.com.bean.cargainicial.CargaInicialBeanLocal;
import co.com.bean.ciudad.CiudadBeanLocal;
import co.com.bean.datosmaestro.DatosMaestroBeanLocal;
import co.com.bean.departamento.DepartamentoBeanLocal;
import co.com.bean.documento.DocumentoBeanLocal;
import co.com.bean.estudiantegrupo.EstudianteGrupoBeanLocal;
import co.com.bean.grupo.GrupoBeanLocal;
import co.com.bean.inscripcion.InscripcionBeanLocal;
import co.com.bean.institucion.InstitucionBeanLocal;
import co.com.bean.maestro.MaestroBeanLocal;
import co.com.bean.matricula.MatriculaBeanLocal;
import co.com.bean.nucleoeducativo.NucleoEducativoBeanLocal;
import co.com.bean.pais.PaisBeanLocal;
import co.com.bean.persona.PersonaBeanLocal;
import co.com.bean.sede.SedeBeanLocal;
import co.com.bean.sedegrados.SedeGradosBeanLocal;
import co.com.bean.sedejornadas.SedeJornadasBeanLocal;
import co.com.bean.zona.ZonaBeanLocal;
import co.com.smart.persistence.entity.AreaFacadeLocal;
import co.com.smart.persistence.entity.AsignaturaFacadeLocal;
import co.com.smart.persistence.entity.CiudadFacadeLocal;
import co.com.smart.persistence.entity.DatosMaestroFacadeLocal;
import co.com.smart.persistence.entity.DepartamentoFacadeLocal;
import co.com.smart.persistence.entity.DocenteFacadeLocal;
import co.com.smart.persistence.entity.DocumentoFacadeLocal;
import co.com.smart.persistence.entity.EstudianteGrupoFacadeLocal;
import co.com.smart.persistence.entity.GrupoFacadeLocal;
import co.com.smart.persistence.entity.InscripcionFacadeLocal;
import co.com.smart.persistence.entity.InstitucionFacadeLocal;
import co.com.smart.persistence.entity.MaestroFacadeLocal;
import co.com.smart.persistence.entity.MatriculaFacadeLocal;
import co.com.smart.persistence.entity.NucleoEducativoFacadeLocal;
import co.com.smart.persistence.entity.PaisFacadeLocal;
import co.com.smart.persistence.entity.PersonaFacadeLocal;
import co.com.smart.persistence.entity.SedeFacadeLocal;
import co.com.smart.persistence.entity.SedeGradosFacadeLocal;
import co.com.smart.persistence.entity.SedeJornadasFacadeLocal;
import co.com.smart.persistence.entity.ZonaFacadeLocal;

public class DelegateContextEJB {

	/**
	 * Beans EJB delegate
	 */
	private static WordBeanLocal wordBeanLocal;
	private static PaisBeanLocal paisBeanLocal;
	private static DepartamentoBeanLocal departamentoBeanLocal;
	private static PersonaBeanLocal personaBeanLocal;
	private static CiudadBeanLocal ciudadBeanLocal;
	private static ZonaBeanLocal zonaBeanLocal;
	private static MaestroBeanLocal maestroBeanLocal;
	private static DatosMaestroBeanLocal datosMaestroBeanLocal;
	private static NucleoEducativoBeanLocal nucleoEducativoBeanLocal;
	private static AreaBeanLocal areaBeanLocal;
	private static AsignaturaBeanLocal asignaturaBeanLocal;
	private static InstitucionBeanLocal institucionBeanLocal;
	private static GrupoBeanLocal grupoBeanLocal;
	private static DocumentoBeanLocal documentoBeanLocal;
	private static SedeBeanLocal sedeBeanLocal;
	private static SedeGradosBeanLocal sedeGradosBeanLocal;
	private static SedeJornadasBeanLocal sedeJornadasBeanLocal;
	private static CargaInicialBeanLocal cargaInicialBeanLocal;
	private static EstudianteGrupoBeanLocal estudianteGrupoBeanLocal;
	private static InscripcionBeanLocal inscripcionBeanLocal;
	private static MatriculaBeanLocal matriculaBeanLocal;
	
	/**
	 * Beans Facade persistentes
	 */
	private static DocenteFacadeLocal docentesLocal;
	private static PaisFacadeLocal paisFacadeLocal;
	private static DepartamentoFacadeLocal departamentoFacadeLocal;
	private static CiudadFacadeLocal ciudadFacadeLocal;
	private static ZonaFacadeLocal zonaFacadeLocal;
	private static PersonaFacadeLocal personaFacadeLocal;
	private static MaestroFacadeLocal maestroFacadeLocal;
	private static DatosMaestroFacadeLocal datosMaestroFacadeLocal;
	private static NucleoEducativoFacadeLocal nucleoEducativoFacadeLocal;
	private static AreaFacadeLocal areaFacadeLocal;
	private static AsignaturaFacadeLocal asignaturaFacadeLocal;
	private static InstitucionFacadeLocal institucionFacadeLocal;
	private static GrupoFacadeLocal grupoFacadeLocal;
	private static DocumentoFacadeLocal documentoFacadeLocal; 
	private static SedeFacadeLocal sedeFacadeLocal;
	private static SedeGradosFacadeLocal sedeGradosFacadeLocal;
	private static SedeJornadasFacadeLocal sedeJornadasFacadeLocal;
	private static EstudianteGrupoFacadeLocal estudianteGrupoFacadeLocal;
	private static InscripcionFacadeLocal inscripcionFacadeLocal;
	private static MatriculaFacadeLocal matriculaFacadeLocal;
	
	/**
	 * BEANS 
	 */
	public static WordBeanLocal getBeanWordLocal(){

		if(wordBeanLocal == null){
			try {
				wordBeanLocal = (WordBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/WordBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return wordBeanLocal;

	}

	public static PaisBeanLocal getPaisBeanLocal(){

		if(paisBeanLocal == null){
			try {
				paisBeanLocal = (PaisBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/PaisBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return paisBeanLocal;

	}

	public static DepartamentoBeanLocal getDepartamentoBeanLocal(){

		if(departamentoBeanLocal == null){
			try {
				departamentoBeanLocal = (DepartamentoBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DepartamentoBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return departamentoBeanLocal;

	}

	
	public static CiudadBeanLocal getCiudadBeanLocal(){
		if(ciudadBeanLocal == null){
			try {
				ciudadBeanLocal = (CiudadBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/CiudadBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return ciudadBeanLocal;
	}

	public static PersonaBeanLocal getPersonaBeanLocal(){

		if(personaBeanLocal == null){
			try {
				personaBeanLocal = (PersonaBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/PersonaBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return personaBeanLocal;

	}

	public static ZonaBeanLocal getZonaBeanLocal(){

		if(zonaBeanLocal == null){
			try {
				zonaBeanLocal = (ZonaBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/ZonaBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return zonaBeanLocal;

	}
	
	public static MaestroBeanLocal getMaestroBeanLocal(){

		if(maestroBeanLocal == null){
			try {
				maestroBeanLocal = (MaestroBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/MaestroBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return maestroBeanLocal;

	}	
	
	public static DatosMaestroBeanLocal getDatosMaestroBeanLocal(){

		if(datosMaestroBeanLocal == null){
			try {
				datosMaestroBeanLocal = (DatosMaestroBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DatosMaestroBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return datosMaestroBeanLocal;

	}
	
	public static NucleoEducativoBeanLocal getNucleoEducativoBeanLocal(){

		if(nucleoEducativoBeanLocal == null){
			try {
				nucleoEducativoBeanLocal = (NucleoEducativoBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/NucleoEducativoBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return nucleoEducativoBeanLocal;

	}
	
	public static AreaBeanLocal getAreaBeanLocal(){
		if(areaBeanLocal == null){
			try{
				areaBeanLocal = (AreaBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/AreaBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return areaBeanLocal;
	}
	
	public static AsignaturaBeanLocal getAsignaturaBeanLocal(){
		if(asignaturaBeanLocal == null){
			try{
				asignaturaBeanLocal = (AsignaturaBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/AsignaturaBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return asignaturaBeanLocal;
	}
	
	public static InstitucionBeanLocal getInstitucionBeanLocal(){
		if(institucionBeanLocal == null){
			try{
				institucionBeanLocal = (InstitucionBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/InstitucionBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return institucionBeanLocal;
	}
	
	public static GrupoBeanLocal getGrupoBeanLocal(){
		if(grupoBeanLocal == null){
			try{
				grupoBeanLocal = (GrupoBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/GrupoBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return grupoBeanLocal;
	}
	
	public static DocumentoBeanLocal getDocumentoBeanLocal(){
		if(documentoBeanLocal == null){
			try{
				documentoBeanLocal = (DocumentoBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DocumentoBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return documentoBeanLocal;
	}
	
	public static SedeBeanLocal getSedeBeanLocal(){
		if(sedeBeanLocal == null){
			try{
				sedeBeanLocal = (SedeBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeBeanLocal;
	}
	
	public static SedeGradosBeanLocal getSedeGradosBeanLocal(){
		if(sedeGradosBeanLocal == null){
			try{
				sedeGradosBeanLocal = (SedeGradosBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeGradosBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeGradosBeanLocal;
	}
	
	public static SedeJornadasBeanLocal getSedeJornadasBeanLocal(){
		if(sedeJornadasBeanLocal == null){
			try{
				sedeJornadasBeanLocal = (SedeJornadasBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeJornadasBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeJornadasBeanLocal;
	}
	
	public static CargaInicialBeanLocal getCargaInicialBeanLocal(){
		if(cargaInicialBeanLocal == null){
			try{
				cargaInicialBeanLocal = (CargaInicialBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/CargaInicialBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return cargaInicialBeanLocal;
	}
	
	public static EstudianteGrupoBeanLocal getEstudianteGrupoBeanLocal(){
		if(estudianteGrupoBeanLocal == null){
			try{
				estudianteGrupoBeanLocal = (EstudianteGrupoBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/EstudianteGrupoBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return estudianteGrupoBeanLocal;
	}
	
	public static InscripcionBeanLocal getInscripcionBeanLocal(){
		if(inscripcionBeanLocal == null){
			try{
				inscripcionBeanLocal = (InscripcionBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/InscripcionBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return inscripcionBeanLocal;
	}
	
	public static MatriculaBeanLocal getMatriculaBeanLocal(){
		if(matriculaBeanLocal == null){
			try{
				matriculaBeanLocal = (MatriculaBeanLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/MatriculaBean");
			}catch (NamingException e){
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return matriculaBeanLocal;
	}
	
	/**
	 * FACADES
	 */

	public static DocenteFacadeLocal getDocentesFacadeLocal() throws NamingException {

		if (docentesLocal == null) {
			docentesLocal 			= (DocenteFacadeLocal)new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DocentesFacade");
		}

		return docentesLocal;
	}

	public static PaisFacadeLocal getPaisFacadeLocal(){

		if(paisFacadeLocal == null){
			try {
				paisFacadeLocal = (PaisFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/PaisFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return paisFacadeLocal;
	}

	public static DepartamentoFacadeLocal getDepartamentoFacadeLocal(){

		if(departamentoFacadeLocal == null){
			try {
				departamentoFacadeLocal = (DepartamentoFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DepartamentoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return departamentoFacadeLocal;
	}

	public static CiudadFacadeLocal getCiudadFacadeLocal(){

		if(ciudadFacadeLocal == null){
			try {
				ciudadFacadeLocal = (CiudadFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/CiudadFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return ciudadFacadeLocal;
	}

	public static ZonaFacadeLocal getZonaFacadeLocal(){

		if(zonaFacadeLocal == null){
			try {
				zonaFacadeLocal = (ZonaFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/ZonaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return zonaFacadeLocal;
	}

	public static PersonaFacadeLocal getPersonaFacadeLocal(){

		if(personaFacadeLocal == null){
			try {
				personaFacadeLocal = (PersonaFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/PersonaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return personaFacadeLocal;
	}
	
	public static MaestroFacadeLocal getMaestroFacadeLocal(){

		if(maestroFacadeLocal == null){
			try {
				maestroFacadeLocal = (MaestroFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/MaestroFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return maestroFacadeLocal;
	}
	
	public static DatosMaestroFacadeLocal getDatosMaestroFacadeLocal(){

		if(datosMaestroFacadeLocal == null){
			try {
				datosMaestroFacadeLocal = (DatosMaestroFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DatosMaestroFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return datosMaestroFacadeLocal;
	}
	
	public static NucleoEducativoFacadeLocal getNucleoEducativoFacadeLocal(){

		if(nucleoEducativoFacadeLocal == null){
			try {
				nucleoEducativoFacadeLocal = (NucleoEducativoFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/NucleoEducativoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return nucleoEducativoFacadeLocal;
	}	
	
	public static AreaFacadeLocal getAreaFacadeLocal(){

		if(areaFacadeLocal == null){
			try {
				areaFacadeLocal = (AreaFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/AreaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return areaFacadeLocal;
	}	

	public static AsignaturaFacadeLocal getAsignaturaFacadeLocal(){

		if(asignaturaFacadeLocal == null){
			try {
				asignaturaFacadeLocal = (AsignaturaFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/AsignaturaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return asignaturaFacadeLocal;
	}	
	
	public static InstitucionFacadeLocal getInstitucionFacadeLocal(){

		if(institucionFacadeLocal == null){
			try {
				institucionFacadeLocal = (InstitucionFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/InstitucionFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return institucionFacadeLocal;
	}
	
	public static GrupoFacadeLocal getGrupoFacadeLocal(){

		if(grupoFacadeLocal == null){
			try {
				grupoFacadeLocal = (GrupoFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/GrupoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return grupoFacadeLocal;
	}
	
	public static DocumentoFacadeLocal getDocumentoFacadeLocal(){

		if(documentoFacadeLocal == null){
			try {
				documentoFacadeLocal = (DocumentoFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/DocumentoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return documentoFacadeLocal;
	}
	
	public static SedeFacadeLocal getSedeFacadeLocal(){

		if(sedeFacadeLocal == null){
			try {
				sedeFacadeLocal = (SedeFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeFacadeLocal;
	}
	
	public static SedeGradosFacadeLocal getSedeGradosFacadeLocal(){

		if(sedeGradosFacadeLocal == null){
			try {
				sedeGradosFacadeLocal = (SedeGradosFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeGradosFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeGradosFacadeLocal;
	}
	
	public static SedeJornadasFacadeLocal getSedeJornadasFacadeLocal(){

		if(sedeJornadasFacadeLocal == null){
			try {
				sedeJornadasFacadeLocal = (SedeJornadasFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/SedeJornadasFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return sedeJornadasFacadeLocal;
	}
	
	public static EstudianteGrupoFacadeLocal getEstudianteGrupoFacadeLocal(){

		if(estudianteGrupoFacadeLocal == null){
			try {
				estudianteGrupoFacadeLocal = (EstudianteGrupoFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/EstudianteGrupoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return estudianteGrupoFacadeLocal;
	}
	
	public static InscripcionFacadeLocal getInscripcionFacadeLocal(){

		if(inscripcionFacadeLocal == null){
			try {
				inscripcionFacadeLocal = (InscripcionFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/InscripcionFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return inscripcionFacadeLocal;
	}
	
	public static MatriculaFacadeLocal getMatriculaFacadeLocal(){

		if(matriculaFacadeLocal == null){
			try {
				matriculaFacadeLocal = (MatriculaFacadeLocal) new InitialContext().lookup("java:global/SmartServicesEAR/SmartServicesEJB/MatriculaFacadeL");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}
		return matriculaFacadeLocal;
	}
}
